package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVO;
import com.itheima.health.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {
    @Select("select id,username,password from t_user where username = #{username}")
    UserVO findUserByUsername(@Param("username") String username);

    @Select("select tr.id,tr.keyword from t_user_role tur,t_role tr where tur.role_id =tr.id and tur.user_id = #{uid}")
    List<RoleVO> findRoleInfoByUserId(@Param("uid") Integer uid);

    @Select("select tp.keyword " +
            "FROM t_role_permission trp , t_permission tp " +
            "WHERE trp.permission_id = tp.id " +
            "and trp.role_id = #{id}")
    List<Permission> findPermissionInfoByRoleId(@Param("id") Integer id);
}
